/*
*			包外壳对象，facade模式，外界通过此类进行统一操作
*/

#pragma once


#include <boost/noncopyable.hpp>

#include "CxIPService.h"
#include "CxGrabThread.h"
#include "CxWriteThread.h"
#include <vector>
#include <boost/signals2/signal.hpp>

namespace ImitateTansfer
{

	using boost::noncopyable;
	using std::vector;

	class CxTransFacade :	public noncopyable
	{


        typedef boost::signals2::signal<void(size_t)>               _PortSignal;
        typedef boost::signals2::signal<void(size_t,double)>        _FrameSignal;

	public:

		CxTransFacade(size_t  portnumber);
		~CxTransFacade(void);
    private:
		
		bool			ChangeCapture(LPCSTR filename , size_t  number);

    public:

        void            DestroyPart();
		void			BuildPart(size_t  portnumber);

    CXSLOTS:
		void			SLOT_connectedclient(size_t);
		void			SLOT_portclose(size_t );

        void            SLOT_setframecount(double ,size_t );
        bool            SLOT_openfile(LPCSTR ,size_t );

    CXSIGNALS:

        _PortSignal             sig_connectclient;
        _PortSignal             sig_portclose;
        _FrameSignal            sig_currentframe;

    public:
        void                    currentFrame(size_t ,double );

        bool                    isBuilded()const{return m_isBuilded;}

	private:
		size_t						m_portnumber;
        bool                        m_isBuilded;
		vector<CxGrabThread *>		m_capturethread;
		vector<CxWriteBuffer*>		m_buffer;
		vector<CxWriteThread*>		m_wirtethread;
		vector<CxPort *>			m_portgroup;
		CxIPService					*m_service;
	};

}
